﻿using System;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Schema;
using System.Xml.XPath;
using System.Collections;
using System.Collections.ObjectModel;
using XmlVisualizer.Models;
using XmlVisualizer.Controllers;
using XmlVisualizer.Views;

namespace XmlVisualizer.Models
{

    #region XML Visual Node

    /// <summary>
    /// Represents one visual node.
    /// </summary>
    public class VisualNode
    {
        /// <summary>
        /// Represents children nodes of the visual node.
        /// </summary>
        public class children : IEnumerable
        {
            #region Members
            private ObservableCollection<VisualNode> VisualChildren = new ObservableCollection<VisualNode>();
            #endregion

            #region Methods

            /// <summary>
            /// Adds the visualNode as a child.
            /// </summary>
            /// <param name="visualChild"></param>
            public void Add(VisualNode visualChild)
            {
                VisualChildren.Add(visualChild);
            }

            /// <summary>
            /// Removes the first occurence of visualChild in the collection.
            /// </summary>
            /// <param name="visualChild">VisualNode to remove</param>
            /// <returns>Return true if visualChild was removed, otherwise returns false.</returns>
            public bool Remove(VisualNode visualChild)
            {
                return VisualChildren.Remove(visualChild);
            }

            #endregion

            #region Properties

            /// <summary>
            /// Returns the number of items in both collections if the same,
            /// otherwise returns 0.
            /// </summary>
            int Count
            {
                get { return VisualChildren.Count; }
            }

            #endregion

            #region IEnumerable Members

            public IEnumerator GetEnumerator()
            {
                return new childEnumerator(VisualChildren);
            }

            #endregion
        }

        public class childEnumerator : IEnumerator
        {
            private ObservableCollection<VisualNode> _children;
            int position = -1;

            public childEnumerator(ObservableCollection<VisualNode> children)
            {
                _children = children;
            }

            #region IEnumerator Members

            public object Current
            {
                get
                {
                    try
                    {
                        return _children[position];
                    }
                    catch (IndexOutOfRangeException)
                    {
                        throw new InvalidOperationException();
                    }
                }
            }

            public bool MoveNext()
            {
                position++;
                return (position < _children.Count);
            }

            public void Reset()
            {
                position = -1;
            }

            #endregion
        }

        /// <summary>
        /// Represents the attributes of the visual node.
        /// </summary>
        public class attributes
        {
            #region Members

            private ObservableCollection<VisualNode> VisualAttributes = new ObservableCollection<VisualNode>();

            #endregion

            #region Methods

            /// <summary>
            /// Adds the node as an attribute.
            /// </summary>
            /// <param name="visual"></param>
            public void Add(VisualNode visual)
            {
                VisualAttributes.Add(visual);
            }

            /// <summary>
            /// Removes the first occurence of visual in the collection.
            /// </summary>
            /// <param name="visual">VisualNode to remove.</param>
            /// <returns>Returns true if item was removed, otherwise returns false.</returns>
            public bool Remove(VisualNode visual)
            {
                return VisualAttributes.Remove(visual);
            }

            #endregion

            #region Properties

            /// <summary>
            /// Returns the number of items in both collections if the same,
            /// otherwise returns 0.
            /// </summary>
            public int Count
            {
                get { return VisualAttributes.Count; }
            }

            public ObservableCollection<VisualNode> visualAttributes
            {
                get { return VisualAttributes; }
            }

            #endregion
        }

        #region M E M B E R S

        private XmlNodeType nodeType;
        private Point position;
        private XmlNode data;
        private children childrenNodes = new children();
        private attributes attributeNodes = new attributes();
        private bool rendered = false;
        private int depth = 0;
        private ControlTemplate appearanceTemplate;
        private ControlTemplate connectorDecoratorTemplate;

        #endregion

        #region P R O P E R T I E S

        public children Children
        {
            get { return childrenNodes; }
        }

        public attributes Attributes
        {
            get { return attributeNodes; }
        }

        public XmlNodeType NodeType
        {
            get { return nodeType; }
            set { nodeType = value; }
        }

        public Point Position
        {
            get { return position; }
            set { position = value; }
        }

        public XmlNode Data
        {
            get { return data; }
            set { data = value; }
        }

        public bool Rendered
        {
            get { return rendered; }
            set { rendered = value; }
        }

        public int Depth
        {
            get { return depth; }
            set { depth = value; }
        }

        public ControlTemplate AppearanceTemplate
        {
            get { return appearanceTemplate; }
            set { appearanceTemplate = value; }
        }

        public ControlTemplate ConnectorDecoratorTemplate
        {
            get { return connectorDecoratorTemplate; }
            set { connectorDecoratorTemplate = value; }
        }

        #endregion
    };

    #endregion

    #region XSD Visual Node

    public class XmlSchemaVisualObject : XmlSchemaObject
    {
        public XmlSchemaVisualObject() { }

        public XmlSchemaVisualObject(Point position)
        {
            Position = position;
        }

        public Point Position { get; set; }
    }

    public class XmlSchemaVisual : XmlSchemaVisualObject
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisual() { }

        public XmlSchemaVisual(ref XmlSchema schema)
        {
            Schema = schema;
        }

        public XmlSchema Schema { get; set; }

        // PROPERTIES we get out of the Schema

        // XmlSchemaForm AttributeFormDefault
        // XmlSchemaDerivationMethod BlockDefault
        // XmlSchemaForm ElementFormDefault
        // XmlSchemaDerivationMethod FinalDefault
        // string Id
        // bool IsCompiled
        // int LineNumber
        // int LinePosition
        // XmlSerializerNamespaces Namespaces
        // XmlSchemaObjectTable SchemaTypes
        // string SourceUri
        // string TargetNamespace
        // XmlAttribute[] UnhandledAttributes
        // string Version

        // PROPERTIES we hold in here

        public XmlSchemaObjectCollection AttributeGroups { get; set; }
        public XmlSchemaObjectCollection Attributes { get; set; }
        public XmlSchemaObjectCollection Elements { get; set; }
        public XmlSchemaObjectCollection Groups { get; set; }
        public XmlSchemaObjectCollection Includes { get; set; }
        public XmlSchemaObjectCollection Items { get; set; }
        public XmlSchemaObjectCollection Notations { get; set; }
    }

    public class XmlSchemaVisualAnnotation : XmlSchemaVisualObject
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualAnnotation() { }

        public XmlSchemaVisualAnnotation(ref XmlSchemaAnnotation schemaAnnotation)
        {
            SchemaAnnotation = schemaAnnotation;
        }

        public XmlSchemaAnnotation SchemaAnnotation { get; set; }
    }

    public class XmlSchemaVisualAppInfo : XmlSchemaVisualObject
    {
        public XmlSchemaVisualAppInfo() { }

        public XmlSchemaVisualAppInfo(ref XmlSchemaAppInfo schemaAppInfo)
        {
            SchemaAppInfo = schemaAppInfo;
        }

        public XmlSchemaAppInfo SchemaAppInfo { get; set; }
    }

    public class XmlSchemaVisualDocumentation : XmlSchemaVisualObject
    {
        public XmlSchemaVisualDocumentation() { }

        public XmlSchemaVisualDocumentation(ref XmlSchemaDocumentation schemaDocumentation)
        {
            SchemaDocumentation = schemaDocumentation;
        }

        public XmlSchemaDocumentation SchemaDocumentation { get; set; }
    }

    public class XmlSchemaVisualExternal : XmlSchemaVisualObject
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualExternal() { }

        public XmlSchemaVisualExternal(ref XmlSchemaExternal schemaExternal)
        {
            SchemaExternal = schemaExternal;
        }

        public XmlSchemaExternal SchemaExternal { get; set; }

        public XmlSchemaVisualAnnotation Annotation { get; set; }
    }

    public class XmlSchemaVisualImport : XmlSchemaVisualExternal
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualImport() { }

        public XmlSchemaVisualImport(ref XmlSchemaImport schemaImport)
        {
            SchemaImport = schemaImport;
        }

        public XmlSchemaImport SchemaImport { get; set; }
    }

    public class XmlSchemaVisualInclude : XmlSchemaVisualExternal
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualInclude() { }

        public XmlSchemaVisualInclude(ref XmlSchemaInclude schemaInclude)
        {
            SchemaInclude = schemaInclude;
        }

        public XmlSchemaInclude SchemaInclude { get; set; }
    }

    public class XmlSchemaVisualRedefine : XmlSchemaVisualExternal
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualRedefine() { }

        public XmlSchemaVisualRedefine(ref XmlSchemaRedefine schemaRedefine)
        {
            SchemaRedefine = schemaRedefine;
        }

        public XmlSchemaRedefine SchemaRedefine { get; set; }
    }

    public class XmlSchemaVisualAnnotated : XmlSchemaVisualObject
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualAnnotated() { }

        public XmlSchemaVisualAnnotated(ref XmlSchemaAnnotated schemaAnnotated)
        {
            SchemaAnnotated = schemaAnnotated;
        }

        public XmlSchemaAnnotated SchemaAnnotated { get; set; }

        public XmlSchemaVisualAnnotation Annotation { get; set; }
    }

    public class XmlSchemaVisualAnyAttribute : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualAnyAttribute() { }

        public XmlSchemaVisualAnyAttribute(ref XmlSchemaAnyAttribute schemaAnyAttribute)
        {
            SchemaAnyAttribute = schemaAnyAttribute;
        }

        public XmlSchemaAnyAttribute SchemaAnyAttribute { get; set; }

        // PROPERTIES we get out of the SchemaAnyAttribute
        // string Id
        // int LineNumber
        // int LinePosition
        // string Namespace
        // XmlSerializerNamespaces Namespaces
        // XmlSchemaContentProcessing ProcessContents
        // string SourceUri
        // XmlAttribute[] UnhandledAttributes

        // PROPERTIES we hold here

        //public XmlSchemaVisualAnnotation Annotation { get; set; }
    }

    public class XmlSchemaVisualAttribute : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualAttribute() { }

        public XmlSchemaVisualAttribute(ref XmlSchemaAttribute schemaAttribute)
        {
            SchemaAttribute = schemaAttribute;
        }

        public XmlSchemaAttribute SchemaAttribute { get; set; }

        public XmlSchemaVisualSimpleType AttributeSchemaType { get; set; }
        // PROPERTIES we get out of the SchemaAttribute
        // string DefaultValue
        // string FixedValue
        // XmlSchemaForm Form
        // string Id
        // int LineNumber
        // int LinePosition
        // string Name
        // XmlSchemaVisualSimpleType AttributeSchemaType
        // XmlSerializerNamespaces Namespaces
        // XmlQualifiedName QualifiedName
        // XmlQualifiedName RefName
        // XmlSchemaSimpleType SchemaType
        // XmlQualifiedName SchemaTypeName
        // string SourceUri
        // XmlAttribute[] UnhandledAttributes
        // XmlSchemaUse Use

        // PROPERTIES we hold here
        //public XmlSchemaVisualAnnotation Annotation { get; set; }
    }

    public class XmlSchemaVisualAttributeGroup : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualAttributeGroup() { }

        public XmlSchemaVisualAttributeGroup(ref XmlSchemaAttributeGroup schemaAttributeGroup)
        {
            SchemaAttributeGroup = schemaAttributeGroup;
        }

        public XmlSchemaAttributeGroup SchemaAttributeGroup { get; set; }

        // PROPERTIES we get out of the SchemaAttributeGroup

        // string Id
        // int LineNumber
        // int LinePosition
        // string Name
        // XmlSerializerNamespaces Namespaces
        // XmlQualifiedName QualifiedName
        // string SourceUri
        // XmlAttribute[] UnhandledAttributes
        
        // PROPERTIES we hold here

        //public XmlSchemaVisualAnnotation Annotation { get; set; }
        public XmlSchemaVisualAnyAttribute AnyAttribute { get; set; }
        public XmlSchemaObjectCollection Attributes { get; set; }
        public XmlSchemaVisualAttributeGroup RedefinedAttributeGroup { get; set; }
    }

    public class XmlSchemaVisualAttributeGroupRef : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualAttributeGroupRef() { }

        public XmlSchemaVisualAttributeGroupRef(ref XmlSchemaAttributeGroupRef schemaAttributeGroupRef) 
        {
            SchemaAttributeGroupRef = schemaAttributeGroupRef;
        }

        public XmlSchemaAttributeGroupRef SchemaAttributeGroupRef { get; set; }
    }

    public class XmlSchemaVisualContent : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualContent() { }

        public XmlSchemaVisualContent(ref XmlSchemaContent schemaContent)
        {
            SchemaContent = schemaContent;
        }

        public XmlSchemaContent SchemaContent { get; set; }
    }

    public class XmlSchemaVisualComplexContentExtension : XmlSchemaVisualContent
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualComplexContentExtension() { }

        public XmlSchemaVisualComplexContentExtension(ref XmlSchemaComplexContentExtension schemaComplexContentExtension)
        {
            SchemaComplexContentExtension = schemaComplexContentExtension;
        }

        public XmlSchemaComplexContentExtension SchemaComplexContentExtension { get; set; }
    }

    public class XmlSchemaVisualComplexContentRestriction : XmlSchemaVisualContent
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualComplexContentRestriction() { }

        public XmlSchemaVisualComplexContentRestriction(ref XmlSchemaComplexContentRestriction schemaComplexContentRestriction)
        {
            SchemaComplexContentRestriction = schemaComplexContentRestriction;
        }

        public XmlSchemaComplexContentRestriction SchemaComplexContentRestriction { get; set; }
    }

    public class XmlSchemaVisualSimpleContentExtension : XmlSchemaVisualContent
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSimpleContentExtension() { }

        public XmlSchemaVisualSimpleContentExtension(ref XmlSchemaSimpleContentExtension schemaSimpleContentExtension)
        {
            SchemaSimpleContentExtension = schemaSimpleContentExtension;
        }

        public XmlSchemaSimpleContentExtension  SchemaSimpleContentExtension { get; set; }
    }

    public class XmlSchemaVisualSimpleContentRestriction : XmlSchemaVisualContent
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSimpleContentRestriction() { }

        public XmlSchemaVisualSimpleContentRestriction(ref XmlSchemaSimpleContentRestriction schemaSimpleContentRestriction)
        {
            SchemaSimpleContentRestriction = schemaSimpleContentRestriction;
        }

        public XmlSchemaSimpleContentRestriction SchemaSimpleContentRestriction { get; set; }
    }

    public class XmlSchemaVisualContentModel : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualContentModel() { }

        public XmlSchemaVisualContentModel(ref XmlSchemaContentModel schemaContentModel)
        {
            SchemaContentModel = schemaContentModel;
        }

        public XmlSchemaContentModel SchemaContentModel { get; set; }
        public XmlSchemaVisualContent Content { get; set; }
    }

    public class XmlSchemaVisualComplexContent : XmlSchemaVisualContentModel
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualComplexContent() { }

        public XmlSchemaVisualComplexContent(ref XmlSchemaComplexContent schemaComplexContent)
        {
            SchemaComplexContent = schemaComplexContent;
        }

        public XmlSchemaComplexContent SchemaComplexContent { get; set; }
    }

    public class XmlSchemaVisualSimpleContent : XmlSchemaVisualContentModel
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSimpleContent() { }

        public XmlSchemaVisualSimpleContent(ref XmlSchemaSimpleContent schemaSimpleContent)
        {
            SchemaSimpleContent = schemaSimpleContent;
        }

        public XmlSchemaSimpleContent SchemaSimpleContent { get; set; }
    }

    public class XmlSchemaVisualFacet : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualFacet() { }

        public XmlSchemaVisualFacet(ref XmlSchemaFacet schemaFacet)
        {
            SchemaFacet = schemaFacet;
        }

        public XmlSchemaFacet SchemaFacet { get; set; }
    }

    public class XmlSchemaVisualEnumerationFacet : XmlSchemaVisualFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualEnumerationFacet() { }

        public XmlSchemaVisualEnumerationFacet(ref XmlSchemaEnumerationFacet schemaEnumerationFacet)
        {
            SchemaFacet = schemaEnumerationFacet;
            SchemaEnumerationFacet = schemaEnumerationFacet;
        }

        public XmlSchemaEnumerationFacet SchemaEnumerationFacet { get; set; }
    }

    public class XmlSchemaVisualMaxExclusiveFacet : XmlSchemaVisualFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualMaxExclusiveFacet() { }

        public XmlSchemaVisualMaxExclusiveFacet(ref XmlSchemaMaxExclusiveFacet schemaMaxExclusiveFacet)
        {
            SchemaFacet = schemaMaxExclusiveFacet;
            SchemaMaxExclusiveFacet = schemaMaxExclusiveFacet;
        }

        public XmlSchemaMaxExclusiveFacet SchemaMaxExclusiveFacet { get; set; }
    }

    public class XmlSchemaVisualMaxInclusiveFacet : XmlSchemaVisualFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualMaxInclusiveFacet() { }

        public XmlSchemaVisualMaxInclusiveFacet(ref XmlSchemaMaxInclusiveFacet schemaMaxInclusiveFacet)
        {
            SchemaFacet = schemaMaxInclusiveFacet;
            SchemaMaxInclusiveFacet = schemaMaxInclusiveFacet;
        }

        public XmlSchemaMaxInclusiveFacet SchemaMaxInclusiveFacet { get; set; }
    }

    public class XmlSchemaVisualMinExclusiveFacet : XmlSchemaVisualFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualMinExclusiveFacet() { }

        public XmlSchemaVisualMinExclusiveFacet(ref XmlSchemaMinExclusiveFacet schemaMinExclusiveFacet)
        {
            SchemaFacet = schemaMinExclusiveFacet;
            SchemaMinExclusiveFacet = schemaMinExclusiveFacet;
        }

        public XmlSchemaMinExclusiveFacet SchemaMinExclusiveFacet { get; set; }
    }

    public class XmlSchemaVisualMinInclusiveFacet : XmlSchemaVisualFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualMinInclusiveFacet() { }

        public XmlSchemaVisualMinInclusiveFacet(ref XmlSchemaMinInclusiveFacet schemaMinInclusiveFacet)
        {
            SchemaFacet = schemaMinInclusiveFacet;
            SchemaMinInclusiveFacet = schemaMinInclusiveFacet;
        }

        public XmlSchemaMinInclusiveFacet SchemaMinInclusiveFacet { get; set; }
    }

    public class XmlSchemaVisualNumericFacet : XmlSchemaVisualFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualNumericFacet() { }

        public XmlSchemaVisualNumericFacet(ref XmlSchemaNumericFacet schemaNumericFacet)
        {
            SchemaFacet = schemaNumericFacet;
            SchemaNumericFacet = schemaNumericFacet;
        }

        public XmlSchemaNumericFacet SchemaNumericFacet { get; set; }
    }

    public class XmlSchemaVisualFractionDigitsFacet : XmlSchemaVisualNumericFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";
        
        public XmlSchemaVisualFractionDigitsFacet() { }

        public XmlSchemaVisualFractionDigitsFacet(ref XmlSchemaFractionDigitsFacet schemaFractionDigitsFacet)
        {
            SchemaFacet = schemaFractionDigitsFacet;
            SchemaFractionDigitsFacet = schemaFractionDigitsFacet;
        }

        public XmlSchemaFractionDigitsFacet SchemaFractionDigitsFacet { get; set; }
    }

    public class XmlSchemaVisualLengthFacet : XmlSchemaVisualNumericFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualLengthFacet() { }

        public XmlSchemaVisualLengthFacet(ref XmlSchemaLengthFacet schemaLengthFacet)
        {
            SchemaFacet = schemaLengthFacet;
            SchemaLengthFacet = schemaLengthFacet;
        }

        public XmlSchemaLengthFacet SchemaLengthFacet { get; set; }
    }

    public class XmlSchemaVisualMaxLengthFacet : XmlSchemaVisualNumericFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualMaxLengthFacet() { }

        public XmlSchemaVisualMaxLengthFacet(ref XmlSchemaMaxLengthFacet schemaMaxLengthFacet)
        {
            SchemaFacet = schemaMaxLengthFacet;
            SchemaMaxLengthFacet = schemaMaxLengthFacet;
        }

        public XmlSchemaMaxLengthFacet SchemaMaxLengthFacet { get; set; }
    }

    public class XmlSchemaVisualMinLengthFacet : XmlSchemaVisualNumericFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualMinLengthFacet() { }

        public XmlSchemaVisualMinLengthFacet(ref XmlSchemaMinLengthFacet schemaMinLengthFacet)
        {
            SchemaFacet = schemaMinLengthFacet;
            SchemaMinLengthFacet = schemaMinLengthFacet;
        }

        public XmlSchemaMinLengthFacet SchemaMinLengthFacet { get; set; }
    }

    public class XmlSchemaVisualTotalDigitsFacet : XmlSchemaVisualNumericFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualTotalDigitsFacet() { }

        public XmlSchemaVisualTotalDigitsFacet(ref XmlSchemaTotalDigitsFacet schemaTotalDigitsFacet)
        {
            SchemaFacet = schemaTotalDigitsFacet;
            SchemaTotalDigitsFacet = schemaTotalDigitsFacet;
        }

        public XmlSchemaTotalDigitsFacet SchemaTotalDigitsFacet { get; set; }
    }

    public class XmlSchemaVisualPatternFacet : XmlSchemaVisualFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualPatternFacet() { }

        public XmlSchemaVisualPatternFacet(ref XmlSchemaPatternFacet schemaPatternFacet)
        {
            SchemaFacet = schemaPatternFacet;
            SchemaPatternFacet = schemaPatternFacet;
        }

        public XmlSchemaPatternFacet SchemaPatternFacet { get; set; }
    }

    public class XmlSchemaVisualWhitespaceFacet : XmlSchemaVisualFacet
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualWhitespaceFacet() { }

        public XmlSchemaVisualWhitespaceFacet(ref XmlSchemaWhiteSpaceFacet schemaWhiteSpaceFacet)
        {
            SchemaFacet = schemaWhiteSpaceFacet;
            SchemaWhiteSpaceFacet = schemaWhiteSpaceFacet;
        }

        public XmlSchemaWhiteSpaceFacet SchemaWhiteSpaceFacet { get; set; }
    }

    public class XmlSchemaVisualGroup : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualGroup() { }

        public XmlSchemaVisualGroup(ref XmlSchemaGroup schemaGroup)
        {
            SchemaGroup = schemaGroup;
        }

        public XmlSchemaGroup SchemaGroup { get; set; }

        // PROPERTIES we get out of the SchemaGroup
        // string Id
        // int LineNumber
        // int LinePosition
        // string Name
        // XmlSerializerNamespaces Namespaces
        // XmlQualifiedName QualifiedName
        // string SourceUri
        // XmlAttribute[] UnhandledAttributes

        // PROPERTIES we hold here
        //public XmlSchemaVisualAnnotation Annotation { get; set; }
        public XmlSchemaVisualGroupBase Particle { get; set; }
    }

    public class XmlSchemaVisualIdentityContstraint : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualIdentityContstraint() { }

        public XmlSchemaVisualIdentityContstraint(ref XmlSchemaIdentityConstraint schemaIdentityConstraint)
        {
            SchemaIdentityConstraint = schemaIdentityConstraint;
        }

        public XmlSchemaIdentityConstraint SchemaIdentityConstraint { get; set; }
    }

    public class XmlSchemaVisualKey : XmlSchemaVisualIdentityContstraint
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualKey() { }

        public XmlSchemaVisualKey(ref XmlSchemaKey schemaKey)
        {
            SchemaKey = schemaKey;
        }

        public XmlSchemaKey SchemaKey { get; set; }
    }

    public class XmlSchemaVisualKeyref : XmlSchemaVisualIdentityContstraint
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualKeyref() { }

        public XmlSchemaVisualKeyref(ref XmlSchemaKeyref schemaKeyref)
        {
            SchemaKeyref = schemaKeyref;
        }

        public XmlSchemaKeyref SchemaKeyref { get; set; }
    }

    public class XmlSchemaVisualUnique : XmlSchemaVisualIdentityContstraint
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualUnique() { }

        public XmlSchemaVisualUnique(ref XmlSchemaUnique schemaUnique)
        {
            SchemaUnique = schemaUnique;
        }

        public XmlSchemaUnique SchemaUnique { get; set; }
    }

    public class XmlSchemaVisualNotation : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualNotation() { }

        public XmlSchemaVisualNotation(ref XmlSchemaNotation schemaNotation)
        {
            SchemaNotation = schemaNotation;
        }

        public XmlSchemaNotation SchemaNotation { get; set; }
    }

    public class XmlSchemaVisualParticle : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualParticle() { }

        public XmlSchemaVisualParticle(ref XmlSchemaParticle schemaParticle)
        {
            SchemaParticle = schemaParticle;
        }

        public XmlSchemaParticle SchemaParticle { get; set; }
    }

    public class XmlSchemaVisualAny : XmlSchemaVisualParticle
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualAny() { }

        public XmlSchemaVisualAny(ref XmlSchemaAny schemaAny)
        {
            SchemaAny = schemaAny;
        }

        public XmlSchemaAny SchemaAny { get; set; }
    }

    /// <summary>
    /// Represents visual appearance of XmlSchemaElement.
    /// </summary>
    public class XmlSchemaVisualElement : XmlSchemaVisualParticle
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualElement() { }

        public XmlSchemaVisualElement(ref XmlSchemaElement schemaElement)
        {
            SchemaElement = schemaElement;
        }

        public XmlSchemaElement SchemaElement { get; set; }
        
        // PROPERTIES we get out of the SchemaElement

        // XmlSchemaDerivationMethod Block
        // XmlSchemaDerivationMethod BlockResolved
        // string DefaultValue
        // XmlSchemaVisualType ElementSchemaType
        // XmlSchemaDerivationMethod Final
        // XmlSchemaDerivationMethod FinalResolved
        // string FixedValue
        // XmlSchemaForm Form
        // string Id
        // bool IsAbstract
        // bool IsNillable
        // int LineNumber
        // int LinePosition
        // decimal MaxOccurs
        // string MaxOccursString
        // decimal MinOccurs
        // string MinOccursString
        // string Name
        // XmlQualifiedName QualifiedName
        // XmlQualifiedName RefName
        // XmlSchemaType SchemaType
        // XmlQualifiedName SchemaTypeName
        // string SourceUri
        // XmlQualifiedName SubstitutionGroup
        // XmlAttribute[] UnhandledAttributes

        // PROPERTIES we hold in here

        //public XmlSchemaVisualAnnotation Annotation { get; set; }
        public XmlSchemaObjectCollection Constraints { get; set; }
    }

    public class XmlSchemaVisualGroupBase : XmlSchemaVisualParticle
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualGroupBase() { }

        public XmlSchemaVisualGroupBase(ref XmlSchemaGroupBase schemaGroupBase)
        {
            SchemaGroupBase = schemaGroupBase;
        }

        public XmlSchemaGroupBase SchemaGroupBase { get; set; }

        // PROPERTIES we get out of the SchemaGroupBase
        // string Id

        public XmlSchemaObjectCollection Items { get; set; }
    }

    public class XmlSchemaVisualAll : XmlSchemaVisualGroupBase
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualAll() { }

        public XmlSchemaVisualAll(ref XmlSchemaAll schemaAll)
        {
            SchemaAll = schemaAll;
        }

        public XmlSchemaAll SchemaAll { get; set; }

        public XmlSchemaObjectCollection Items { get; set; }

        // PROPERTIES we get out of the SchemaAll
        // string Id

        // PROPERTIES we hold here


    }

    public class XmlSchemaVisualChoice : XmlSchemaVisualGroupBase
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualChoice() { }

        public XmlSchemaVisualChoice(ref XmlSchemaChoice schemaChoice)
        {
            SchemaChoice = schemaChoice;
        }

        public XmlSchemaChoice SchemaChoice { get; set; }
    }

    public class XmlSchemaVisualSequence : XmlSchemaVisualGroupBase
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSequence() { }

        public XmlSchemaVisualSequence(ref XmlSchemaSequence schemaSequence)
        {
            SchemaSequence = schemaSequence;
        }

        public XmlSchemaSequence SchemaSequence { get; set; }
    }

    public class XmlSchemaVisualGroupRef : XmlSchemaVisualParticle
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualGroupRef() { }

        public XmlSchemaVisualGroupRef(ref XmlSchemaGroupRef schemaGroupRef)
        {
            SchemaGroupRef = schemaGroupRef;
        }

        public XmlSchemaGroupRef SchemaGroupRef { get; set; }
    }

    public class XmlSchemaVisualSimpleTypeContent : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSimpleTypeContent() { }

        public XmlSchemaVisualSimpleTypeContent(ref XmlSchemaSimpleTypeContent schemaSimpleTypeContent)
        {
            SchemaSimpleTypeContent = schemaSimpleTypeContent;
        }

        public XmlSchemaSimpleTypeContent SchemaSimpleTypeContent { get; set; }
    }

    public class XmlSchemaVisualSimpleTypeList : XmlSchemaVisualSimpleTypeContent
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSimpleTypeList() { }

        public XmlSchemaVisualSimpleTypeList(ref XmlSchemaSimpleTypeList schemaSimpleTypeList)
        {
            SchemaSimpleTypeList = schemaSimpleTypeList;
        }

        public XmlSchemaSimpleTypeList SchemaSimpleTypeList { get; set; }
        public XmlSchemaVisualSimpleType BaseItemType { get; set; }

    }

    public class XmlSchemaVisualSimpleTypeRestriction : XmlSchemaVisualSimpleTypeContent
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSimpleTypeRestriction() { }

        public XmlSchemaVisualSimpleTypeRestriction(ref XmlSchemaSimpleTypeRestriction schemaSimpleTypeRestriction)
        {
            SchemaSimpleTypeRestriction = schemaSimpleTypeRestriction;
        }

        public XmlSchemaSimpleTypeRestriction SchemaSimpleTypeRestriction { get; set; }

        public XmlSchemaObjectCollection facets { get; set; }
    }

    public class XmlSchemaVisualSimpleTypeUnion : XmlSchemaVisualSimpleTypeContent
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSimpleTypeUnion() { }

        public XmlSchemaVisualSimpleTypeUnion(ref XmlSchemaSimpleTypeUnion schemaSimpleTypeUnion)
        {
            SchemaSimpleTypeUnion = schemaSimpleTypeUnion;
        }

        public XmlSchemaSimpleTypeUnion SchemaSimpleTypeUnion { get; set; }

        public XmlSchemaObjectCollection BaseTypes { get; set; }
    }

    public class XmlSchemaVisualType : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualType() { }

        public XmlSchemaVisualType(ref XmlSchemaType schemaType)
        {
            SchemaType = schemaType;
        }

        public XmlSchemaType SchemaType { get; set; }

        // PROPERTIES we get out of the SchemaType
        // XmlSchemaDatatype Datatype
        // XmlSchemaDerivationMethod DerivedBy
        // XmlSchemaDerivationMethod Final
        // XmlSchemaDerivationMethod FinalResolved
        // string Id
        // bool IsMixed
        // int LineNumber
        // int LinePosition
        // string Name
        // XmlSerializerNamespaces Namespaces
        // XmlQualifiedName QualifiedName
        // string SourceUri
        // XmlTypeCode TypeCode
        // XmlAttribute[] UnhandledAttributes

        // PROPERTIES we hold here
        //public XmlSchemaVisualAnnotation Annotation { get; set; }
        public XmlSchemaVisualType BaseXmlSchemaType { get; set; }
    }

    public class XmlSchemaVisualComplexType : XmlSchemaVisualType
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualComplexType() { }

        public XmlSchemaVisualComplexType(ref XmlSchemaComplexType schemaComplexType)
        {
            SchemaComplexType = schemaComplexType;
        }

        public XmlSchemaComplexType SchemaComplexType { get; set; }
        public XmlSchemaVisualAnyAttribute AnyAttribute { get; set; }
        public XmlSchemaObjectCollection Attributes { get; set; }
        public XmlSchemaVisualContentModel ContentModel { get; set; }
        public XmlSchemaVisualParticle ContentTypeParticle { get; set; }

    }

    public class XmlSchemaVisualSimpleType : XmlSchemaVisualType
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualSimpleType() { }

        public XmlSchemaVisualSimpleType(ref XmlSchemaSimpleType schemaSimpleType)
        {
            SchemaSimpleType = schemaSimpleType;
        }

        public XmlSchemaSimpleType SchemaSimpleType { get; set; }

        public XmlSchemaVisualSimpleTypeContent Content { get; set; }

        
        // PROPERTIES we get out of the SchemaSimpleType
        // XmlSchemaDatatype Datatype
        // XmlSchemaDerivationMethod DerivedBy
        // XmlSchemaDerivationMethod Final
        // XmlSchemaDerivationMethod FinalResolved
        // string Id
        // bool IsMixed
        // int LineNumber
        // int LinePosition
        // string Name
        // XmlSerializerNamespaces Namespaces
        // XmlQualifiedName QualifiedName
        // string SourceUri
        // XmlTypeCode TypeCode
        // XmlAttribute[] UnhandledAttributes
        // XmlSchemaVisualSimpleTypeContent Content

        // PROPERTIES we hold here
        //public XmlSchemaVisualAnnotation Annotation { get; set; }
        //public XmlSchemaVisualType BaseXmlSchemaType { get; set; }
    }

    public class XmlSchemaVisualXPath : XmlSchemaVisualAnnotated
    {
        public static string defaultAppearanceTemplate = "AppearanceProcess";
        public static string defaultConnectorTemplate = "ConnectorDecoratorDefaultTemplate";

        public XmlSchemaVisualXPath() { }

        public XmlSchemaVisualXPath(ref XmlSchemaXPath schemaXPath)
        {
            SchemaXPath = schemaXPath;
        }

        public XmlSchemaXPath SchemaXPath { get; set; }
    }

    #endregion
}